<template>
    <div class="gray">
        <search></search>
        <div class="flower">
            <ul v-if="isShow">
                <li>
                    <div class="content" @click="rouAddress">
                        <div class="inners">
                            <div class="p">{{moreList.name}}</div>
                            <span class="more" v-if="moreList.is_default == 1">默认</span>
                        </div>
                        <div class="inne">
                            <p>{{moreList.mobile}}</p>
                            <p>{{moreList.address}}</p>
                        </div>
                        <van-icon name="share-o" size="25"/>
                    </div>
                </li>

                <!-- <li v-else>
                    <div class="content" @click="rouAddress">
                        <div class="inners">
                            <div class="p">{{lists[0].name}}</div>
                            <span class="more" v-if="lists[0].is_default == 1">默认</span>
                        </div>
                        <div class="inne">
                            <p>{{lists[0].mobile}}</p>
                            <p>{{lists[0].address}}</p>
                        </div>
                        <van-icon name="share-o" size="25"/>
                    </div>
                </li> -->
            </ul>
            <p v-else class="select" @click="rouAddress">请选择收货地址 </p>
        </div>
        <div class="box">
            <div class="inner">
                <p>商品合计</p>
                <p>￥{{price}}</p>
            </div>
            <div class="inner">
                <p>运费</p>
                <p>免运费</p>
            </div>
            <div class="inner">
                <p>优惠券</p>
                <p>暂无</p>
            </div>
        </div>
        <div class="fixed">
            <p>实付: ￥{{price}}</p>
            <p @click="payment">支付</p>
        </div>
        <div class="boxs">
            <ul>
                <li v-for="item in list" :key="item.id">
                    <div class="left">
                        <img :src="item.list_pic_url" width="62.5" height="62.5">
                        <div class="inner">
                            <p>{{item.goods_name}}</p>
                            <p>￥{{item.retail_price}}</p>
                        </div>
                    </div>
                    <div class="right">x{{item.number}}</div>
                </li>
            </ul>
        </div>
        <div class="height"></div>
    </div>
</template>

<script>

import search from "@/components/search"
import { detailAction } from "@/api/home/order/index.js"
import { Toast } from 'vant';
export default {
    data() {
        return {
            price:"",
            list:[],
            moreList:{},
            lists:[],
            show:false,
            isShow:true,
        };
    },
    methods: {
        init(){
               detailAction({
                   openId:localStorage.getItem("openId"),
                   addressId:""
               }).then(res=>{
                   this.price = res.data.allPrise;
                   this.list = res.data.goodsList,
                   this.moreList = JSON.parse(localStorage.getItem("item"));
                   this.lists = JSON.parse(localStorage.getItem("list"));
                   this.isShow = this.lists.some(ele => ele.id == this.moreList.id);
                    
                   if(this.lists.length == 0){
                       this.show = false
                   }else{
                       this.show = true
                   }
                //    console.log(this.moreList);
               })
        },
         rouAddress(){
          this.$router.push({path:"/my/address"})
         },
         payment(){
            Toast.fail('支付功能暂未开发');
         }
    },
    created() {
        this.init();
    },
    computed: {

    },
    components:{
        search
    },
    mounted() {

    },
};
</script>

<style scoped lang="scss">
.gray{
    background-color: rgb(244,244,244);
}
    .flower{
        background-color: #fff;
        width: 100%;
        height: 83px;
        background: url(~@/assets/hua.png) repeat-x #fff;
        background-size: .82667rem .13333rem;
        margin-bottom: 10px;
        padding-top: 15px;
        line-height: 88px;
        .select{
            margin: 0;
            line-height: 83px;
        }
        ul{
            height: 100%;
            padding: 0 10px;
            li{
                height: 100%;
               .content{
                   height: 100%;
                   display: flex;
                   width: 100%;
                   align-items: center;
                   .inners{
                       height: 100%;
                       display: flex;
                       flex-direction: column;
                       align-items: center;
                       justify-content: center;
                       width: 50px;
                       .p{
                            line-height: 18px;
                            margin-bottom:5px;
                       }
                       .more{
                            z-index: 20;
                            width: .8rem;
                            height: .4rem;
                            border: 1Px solid #b4282d;
                            text-align: center;
                            line-height: .4rem;
                            color: #b4282d;
                            padding: 1;
                            margin: 5px 9px 0px 9px;
                       }
                   }
                  .inne{
                       height: 100%;
                       width: 240px;
                       padding: 0 10px;
                       display: flex;
                       flex-direction: column;
                        p{
                            margin: 13px 0;
                            height: 14px;
                            text-align: left;
                            transform: translateY(-30px);
                        }
                        p:last-child{
                            margin: 0;
                        }
                       
                    }
               } 
            }
        }
    }
    .box{
        height: 140px;
        padding: 0 15px;
        background-color: #fff;
        display: flex;
        flex-direction: column;
        .inner{
            border-bottom: 1Px solid #d9d9d9;
            margin: 0;
            padding: 15px 0;
            display: flex;
            justify-content: space-between;
            p{
                margin: 0;
            }
        }
    }
    .height{
        background-color: #fff;
        height: 50px;
    }
    .fixed{
        position: fixed;
        left: 0;
        bottom:0px;
        height: 50px;
        display: flex;
        padding-left: 10px;
        width: 365px;
        background-color: rgb(244, 244, 244);
        justify-content: space-between;
        align-items: center;
         p:last-child{
                text-align: center;
                background: #b4282d;
                color: #fff;
                width: 100px;
                height: 50px;
                margin: 0;
                line-height: 50px;
                margin-left:20px;
        }
    }

    .boxs{
        width: 100%;
        margin-top:10px;
        margin-bottom:10px;
        ul{
            padding: 0 10px;
            background-color: #fff;
            li{
                display: flex;
                align-items: center;
                justify-content: space-between;
                padding: 10px 0;
                .left{
                    display: flex;
                    align-items: center;
                    img{
                         background-color: rgb(244, 244, 244);
                         margin-left:10px;
                    }
                    .inner{
                        padding: 10px;
                        display: flex;
                        align-items: center;
                        flex-direction: column;
                        p{
                            text-align: left !important;
                            margin: 8px 0;
                            width: 100%;
                        }
                    }
                }
                .right{
                    margin-right:25px ;
                }
            }
        }

    }
</style>
